<template>
	<view class="coupon-item">
		<view class="coupon-money">
			<view class="layof" v-if="itemType==0">￥{{itemData.coupon_price/100}}</view>
			<view class="layof" v-if="itemType==1">X{{itemData.count}}</view>
			<view class="end_time" style="margin: 16rpx 0;">优惠券名称:{{itemData.coupon_name}}</view>
			<view class="end_time" v-if="itemType==1">有效时间:{{getDate(itemData.validity)}}</view>
		</view>
		<view class="get-btn" @tap="itemClick">{{itemType==0?'立即购买':'立即使用'}}</view>
	</view>
</template>
<script>
	export default {
		props: {
			itemData: {
				type: Object,
				default: {},
			},
			itemType: {
				type: Number,
				default: 0,
			}
		},
		data() {
			return {

			}
		},
		methods: {
			itemClick() {
				this.$emit('itemClick', this.itemData)
			}
		}
	}
</script>

<style lang='scss'>
	.coupon-item {
		/* width: 100%; */
		width: 660rpx;
		height: auto;
		display: table;
		border-radius: 10upx;
		padding: 0 20upx;
		margin-top: 22upx;
		border: 1px solid #eeeeee;
		position: relative;

		.coupon-money {
			width: 465upx;
			height: auto;
			display: table;
			float: left;
			padding: 26upx 0;
			border-style: none dotted none none;
			border-color: #eeeeee;

			.nick {
				width: 100%;
				height: 50upx;
				line-height: 30upx;
				font-size: 28rpx;
				color: #fff;
			}

			.tit {
				width: 100%;
				height: 50upx;
				line-height: 50upx;
				font-size: 28rpx;
				color: #fff;
			}

			.demand {
				width: 100%;
				height: 30upx;
				line-height: 30upx;
				font-size: 28rpx;
				color: #fff;
			}

			.layof {
				width: 100%;
				height: 48upx;
				line-height: 30upx;
				font-size: 44upx;
				color: #ff9000;
				font-weight: bold;
			}

			.end_time {
				width: 100%;
				height: 30upx;
				line-height: 30upx;
				font-size: 28rpx;
				color: #999999;
			}
		}

		.get-btn {
			width: 146upx;
			height: 52upx;
			line-height: 50upx;
			position: absolute;
			top: 50%;
			right: 26upx;
			margin-top: -26upx;
			text-align: center;
			border-radius: 60upx;
			color: #ff9000;
			border: 1px solid #ff9000;
			font-size: 28rpx;
			float: right;
		}
	}

	.coupon-item:after {
		width: 40upx;
		height: 20upx;
		position: absolute;
		left: 460upx;
		top: -1px;
		border-radius: 0 0 40upx 40upx;
		content: "";
		display: block;
		background: #fff;
		border: 1px solid #eeeeee;
		border-top: 0px;
	}

	.coupon-item:before {
		width: 40upx;
		height: 20upx;
		position: absolute;
		left: 460upx;
		bottom: -1px;
		border-radius: 40upx 40upx 0 0;
		content: "";
		display: block;
		background: #fff;
		border: 1px solid #eeeeee;
		border-bottom: 0px;
	}
</style>
